/**
 * 
 */
package com.wodsy.phoenix.apps.cms.homepage.controller;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wodsy.phoenix.dataobject.base.Pager;
import com.wodsy.phoenix.dataobject.cms.model.IdxCustomizePic;
import com.wodsy.phoenix.dataservice.cms.service.CmsHomePageCustomizePicService;

/**
 * @author bryan
 *
 */
@RequestMapping("/cmsCustomizePic")
@Controller
public class CmsHomePageIndexCustomizePicController {
	private Logger logger = LoggerFactory.getLogger(CmsHomePageIndexCustomizePicController.class);
	@Autowired
	private CmsHomePageCustomizePicService cmsHomePageCustomizePicService;

	/**
     * 导向首页面
     *
     * @param request 请求
     * @return
     */
    @RequestMapping(value = "/index", method = RequestMethod.GET)
    public String index(HttpServletRequest request) {
        return "/customizePic";
    }
    
    /**
	 * 增加一条customizePic
	 */
    @RequestMapping(value = "/addOneCustomizePic", method = RequestMethod.POST)
    @ResponseBody
    public void addOneCustomizePic(IdxCustomizePic customizePic){
		cmsHomePageCustomizePicService.save(customizePic);
	}
	/**
	 * 获取一条customizePic信息
	 */
    @RequestMapping(value = "/getOneCustomizePic/{picId}", method = RequestMethod.GET)
    @ResponseBody
	public IdxCustomizePic getOneCustomizePic(@PathVariable Integer picId){
    	IdxCustomizePic customizePic = cmsHomePageCustomizePicService.get(picId);
    	return customizePic;
		
	}
	/**
	 * 修改一条customizePic信息
	 */
    @RequestMapping(value = "/updateOneCustomizePic", method = RequestMethod.POST)
    @ResponseBody
    public void updateOneCustomizePic(IdxCustomizePic customizePic){
    	customizePic.setUpdateTime(new Date());
		cmsHomePageCustomizePicService.updateCustomizePicRecommended(customizePic);//.update(customizePic);
	}
	/**
	 * 根据搜索条件查询customizePicList
	 */
    @RequestMapping(value = "/getAllCustomizePicByOrder", method = RequestMethod.POST)
    @ResponseBody
	public Pager<IdxCustomizePic> getAllCustomizePicByOrder(int pageSize,int pageNo,IdxCustomizePic picreq){
		Pager<IdxCustomizePic> picRec = new Pager<>();
		picRec.setPageSize(pageSize);
		picRec.setPageNo(pageNo);
		
		Pager<IdxCustomizePic> picPager = cmsHomePageCustomizePicService.searchHotGoodsRecByOrder(picRec, picreq);
	
		return picPager;
	}
	/**
	 * 更新pic状态
	 */
    @RequestMapping(value = "/updatePicCustomizePicStatus", method = RequestMethod.POST)
    @ResponseBody
    public void updatePicCustomizePicStatus(Integer picId,Integer status){
		cmsHomePageCustomizePicService.updateCustomizePicStatus(picId, status);
	}
	/**
	 * 更新picList状态
	 */
    @RequestMapping(value = "/updatePicCustomizePicStatusList", method = RequestMethod.POST)
    @ResponseBody
    public void updatePicCustomizePicStatusList(Integer[] picIds,Integer status){
		cmsHomePageCustomizePicService.updateCustomizePicStatus(picIds, status);
	}
    
}
